home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 143
/
Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).7z
/
Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).bin
/
ikap
/
grp1
/
smp2
/
spctest.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-03-06
|
4KB
|
233 lines
/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <iocslib.h>
#include "structs.inc"
extern int HEY1[],YA00[];
TASK ETask[MAX_ETASK]; /*クリック可能アイテム*/
#define SetTask(tn,na,x,y,an) \
t=&ETask[(tn)]; \
t->disp0_addr=(na); \
t->disp0_x=(x)<<16; \
t->disp0_y=(y)<<16; \
t->disp0_anim=(an)
int Init000()
{
TASK *t;
CRTMOD(270);
HOME(0,0,0);
cls();
sp_init();
v_priority("TSG","0123");
sp_disp(1);
sp_on(0,127);
mouse(1);
spfile_def("mue_m.SP",0x00); /*スプライト読み込み*/
palfile_def("mue.PAL",0x01);
/* t=&ETask[0]; t->disp0_addr=YOUW; t->disp0_x=128<<16; t->disp0_y=128<<16; t->disp0_anim=0; */
SetTask(0,HEY1,228,180,0);
SetTask(1,YA00,228,180,0);
}
/*----------------------------------------------------------------------SyncMan()*/
#define X6sp_set(pl,x,y,n,p) \
X6sync_buf[(pl)*4+0]=(x); \
X6sync_buf[(pl)*4+1]=(y); \
X6sync_buf[(pl)*4+2]=(n); \
X6sync_buf[(pl)*4+3]=(p)
short X6sync_buf[128*4];
int SyncMan()
{
int ssp;
short d,sppl;
short tn,sn,an,px,py,pat;
TASK *t; /*通常タスク*/
SPINFO *s;
ssp=B_SUPER(0);
sppl=0;
/*敵機
*/
for( tn=0;tn<MAX_ETASK;tn++ ){
t=&ETask[tn];
/* if( t->func_addr==NULL ){ continue; } */
if( t->disp0_addr==NULL ){ continue; }
s=t->disp0_addr;
if( s==NULL ){ continue; }
/*以下、表示
*/
an=t->disp0_anim;
px=*(short *)&(t->disp0_x);
py=*(short *)&(t->disp0_y);
for( sn=0;sn<s->anim_info[t->disp0_anim]->chips;sn++ ){
px+=s->anim_info[t->disp0_anim]->splink[sn].ox;
py+=s->anim_info[t->disp0_anim]->splink[sn].oy;
pat=s->anim_info[t->disp0_anim]->splink[sn].patnum;
if( t->disp0_palet!=0 ){
pat&=0xf0ff;
pat=pat|(t->disp0_palet<<8);
}
X6sp_set(
sppl, /*実際に描画されるSPプレーン*/
px,
py,
pat,
3
);
sppl++;
}
}
/*スクロール
*/
{
int pn;
unsigned short *spscr=0xEB0000,
*sync=X6sync_buf;
for( pn=0;pn<min(sppl,128);pn++ ){
*spscr++=(*sync+16);sync++;
*spscr++=(*sync+16);sync++;
*spscr++=*sync++;
*spscr++=*sync++;
}
sp_off(sppl,127);
}
{
unsigned short *vctrl_r2=0xE82600;
*vctrl_r2|=0x0040;
}
B_SUPER(ssp);
}
int voffwait(times)
int times;
{
volatile unsigned char *gpip=0xe88001;
int t,ssp;
ssp=B_SUPER(0);
for( t=0;t<times;t++ ){
while((*gpip&0x10));
while(!(*gpip&0x10));
}
B_SUPER(ssp);
}
void Idle()
{
static int local_counter;
short *anum;
int *dx,*dy,*vx,*vy;
int mx,my;
mspos(&mx,&my);
/*弓引き兵隊
*/
anum=&(ETask[0].disp0_anim);
switch( local_counter%60 ){
case 0: *anum=0; break;
case 3: *anum=1; break;
case 6: *anum=2; break;
case 9: *anum=3; break;
}
/*矢
*/
anum=&(ETask[1].disp0_anim);
vx=(int *)&(ETask[1].work[0]);
vy=(int *)&(ETask[1].work[2]);
dx=(int *)&(ETask[1].work[4]);
dy=(int *)&(ETask[1].work[6]);
switch( local_counter%60 ){
case 0:
*anum=0;
*vx=0;
*vy=0;
*dx=0;
*dy=0;
ETask[1].disp0_x=ETask[0].disp0_x;
ETask[1].disp0_y=ETask[0].disp0_y;
break;
case 9:
*anum=1;
/*
*vx=-0x100000;
*vy=-0x10000;
*/
*vx=-(rand()%32+32)<<12;
*vy=-(rand()%32+16)<<12;
*dx=0;
*dy=-(*vy/12);
break;
}
if( (local_counter%60)>9 ){
*vx+=*dx; //加速
*vy+=*dy;
}
ETask[1].disp0_x+=*vx;
ETask[1].disp0_y+=*vy;
local_counter++;
}
main(argc,argv)
int argc;
char *argv[];
{
int mn;
Init000();
mn=(ETask[0].disp0_addr)->max_anim;
while( BITSNS(0)!=0x02 ){
SyncMan();
Idle();
voffwait(1);
}
while( BITSNS(0)==0x02 );
KFLUSHIO(0xff);
}
/* [ EOF ] */